<template>
  <div>
    <el-form id="formData" ref="formData" :model="formData" status-icon>
      <el-row>
        <el-col :span="12">
          <el-form-item label="委托单号" :label-width="formLabelWidth">
            {{ formData.orderNum }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="委托科室" :label-width="formLabelWidth">
            {{ formData.department }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="委托时间" :label-width="formLabelWidth">
            {{ formData.entrustDateTime }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="计划检测时间" :label-width="formLabelWidth">
            {{ formData.planDetectionDate }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="方法标准" :label-width="formLabelWidth">
            {{ formData.methodStandard }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="方法标准名称" :label-width="formLabelWidth">
            {{ formData.methodStandardName }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="检测人" :label-width="formLabelWidth">
            <el-input v-model="formData.resultDetectionPerson" disabled />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-table
      :data="formData.entrustTaskSampleInfoResultDtos"
      element-loading-text="Loading"
      fit
      height="270px"
      highlight-current-row
    >
      <!-- <el-table-column type="selection" width="55"> </el-table-column> -->
      <el-table-column align="center" label="序号" width="50">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column style="text-align: left" label="样品编号">
        <template slot-scope="scope">
          <div style="text-align: center">{{ scope.row.sampleNum }}</div>
        </template>
      </el-table-column>
      <el-table-column style="text-align: left" label="受检单位/地址">
        <template slot-scope="scope">
          {{ scope.row.address }}
        </template>
      </el-table-column>
      <el-table-column label="样品类别名称">
        <template slot-scope="scope">
          {{ scope.row.sampleCategoryName }}
        </template>
      </el-table-column>
      <el-table-column label="检测项目">
        <template slot-scope="scope">
          {{ scope.row.detectionItem }}
        </template>
      </el-table-column>
      <el-table-column label="项目分项">
        <template slot-scope="scope">
          {{ scope.row.minuteItem }}
        </template>
      </el-table-column>

      <el-table-column label="单位符号">
        <template slot-scope="scope">
          {{ scope.row.unitSymbol }}
        </template>
      </el-table-column>
      <el-table-column label="检测结果">
        <template slot-scope="scope">
          {{ scope.row.result }}
        </template>
      </el-table-column>
      <el-table-column label="质量指标">
        <template slot-scope="scope">
          {{ scope.row.qualityIndex }}
        </template>
      </el-table-column>
      <el-table-column label="检测结果状态">
        <template slot-scope="scope">
          {{ scope.row.resultStatus }}
        </template>
      </el-table-column>
      <el-table-column label="是否检测">
        <template slot-scope="scope">
          <el-checkbox v-model="scope.row.detectionStateBool" :disabled="true"
            >不检测</el-checkbox
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import {
  entrustTaskResultVerifyList,
  entrustTaskSampleInfoResult,
} from "./api/EntrustTaskManage/EntrustTask.js";
import {
  entrustTaskSampleInfoVerifyReject,
  entrustTaskSampleInfoVerifyPass,
} from "./api/EntrustTaskManage/EntrustTaskSampleInfo.js";

import { formatTime } from "@/utils/time";
export default {
  name: "AuditEntrustTaskDataAuditDetails",
  props: {
    row: {
      type: Object,
      default: () => {},
    },
    data: {
      type: Object, // 数组 // 对象或数组默认值必须从一个工厂函数获取
      default: () => {},
    },
    fromSource: {
      type: String, // 数组 // 对象或数组默认值必须从一个工厂函数获取
      default: "",
    },
  },
  data() {
    return {
      list: [],
      formLabelWidth: "100px",
      formData: {
        entrustTaskNum: "",
        entrustOrderNumList: "",
        detectionItemName: "",
        sampleInfoName: "",
        sampleInfoNum: "",
        planDetectionDate: "",
        remark: "",
      },
      pageInfo: {
        pageIndex: 1,
        pageSize: 10,
      },
    };
  },
  watch: {},
  created() {
    if (this.fromSource === "verify") {
      this.getList(this.row.auditDataId);
    } else {
      this.getList(this.entrustOrderId);
    }
  },
  methods: {
    formatTime,
    innerEntrustTaskResultVerifyList(obj) {
      entrustTaskResultVerifyList(obj)
        .then((res) => {
          this.$emit("passOrNoPassEmit");
        })
        .catch();
    },

    getList(id) {
      this.list = [];
      var obj = {};
      obj.entrustTaskIdList = id;
      entrustTaskSampleInfoResult(obj).then((res) => {
        this.formData = res.data;
        if (
          res.data.resultDetectionPerson !== null &&
          res.data.resultDetectionPerson !== ""
        ) {
          this.formData.resultDetectionPerson = res.data.resultDetectionPerson;
        } else {
          this.formData.resultDetectionPerson = this.$store.getters.name;
          this.formData.resultDetectionPersonId =
            this.$store.getters.currentUserId;
        }
      });
    },

    innerPass(obj) {
      entrustTaskSampleInfoVerifyPass(obj)
        .then((res) => {
          this.$emit("passOrNoPassEmit");
        })
        .catch();
    },
    innerReject(obj) {
      entrustTaskSampleInfoVerifyReject(obj)
        .then((res) => {
          this.$emit("passOrNoPassEmit");
        })
        .catch();
    },
    innerWithdraw(obj) {
      obj.auditStatus = 60;
      entrustTaskSampleInfoVerifyReject(obj)
        .then((res) => {
          this.$emit("passOrNoPassEmit");
        })
        .catch();
    },
  },
};
</script>
<style scoped>
.el-form-item__content {
  text-align: left !important;
}
</style>
